package com.benson.generic.bound;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class GenericAndCovariance {

	public static void main(String[] args) {
		List<? extends Fruit> flist = new ArrayList<Apple>();
		
		//flist.add(new Fruit()); error:
		Apple apple = new Apple();
		Orange orange = new Orange();
		List<? extends Fruit> slist = Arrays.asList(apple,orange,new Blanana());
		
		System.out.println(slist.contains(apple));
		System.out.println(slist.contains(orange));
		System.out.println(slist.indexOf(apple));
		System.out.println(slist.indexOf(orange));
		//= List<Fruit> slist = Arrays.asList(apple,orange,new Blanana());
		
	}
}

class Fruit{}

class Apple extends Fruit{}

class Orange extends Fruit{}

class Blanana extends Fruit{}
